package cn.ggy;

import cn.ggy.demo.Phone;
import cn.ggy.demo.ProxyPhone;
import cn.ggy.demo.XiaoMi;
import cn.ggy.demo2.HuaWei;
import cn.ggy.demo2.ProxyPhone2;
import org.junit.Test;

public class MyTest1 {

    @Test
    public void t1(){

        XiaoMi xiaoMi = new XiaoMi();
        ProxyPhone proxyPhone = new ProxyPhone(xiaoMi);
        proxyPhone.say();
    }

    @Test
    public void t2(){

        ProxyPhone2 proxyPhone2 = new ProxyPhone2(new HuaWei());
        //生成代理对象 (其类型只能是接口的 因为jdk中的代理是基于接口的)
        Phone proxyPhone = (Phone)proxyPhone2.getProxyPhone();
        proxyPhone.say();

    }
}
